
package com.hmsg.health.dao;

import com.hmsg.health.bean.Dto.TaskDto;
import com.hmsg.health.bean.domain.InviteDo;
import com.hmsg.health.bean.domain.TaskDo;
import com.hmsg.health.bean.domain.UserDo;
import com.hmsg.health.bean.domain.WithdrawDo;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface InviteDao {
	
    @Select("select * from s_invite where id=#{id}")
    InviteDo findOne(@Param("id")Integer id);
    
   
    
    
    @Select("<script>" +
    	    "select * from  `s_invite` where 1=1 " +
    	    "    <if test='info.id != null'>" +
    	    "     and `id` = #{info.id} " +
    	    "    </if>" +
    	    "    <if test='info.inviteId != null'>" +
    	    "    and  `invite_id` = #{info.inviteId} " +
    	    "    </if>" +
    	    "    <if test='info.userId != null'>" +
    	    "    and  `user_id` = #{info.userId} " +
    	    "    </if>" +
    	
    	    "    order by id desc" +
 
    	    "</script>")
    List<InviteDo> select(@Param("info") InviteDo info);
    
    
   
    @Delete("delete from s_invite where id=#{userId}")
    int delete(Integer userId);
    
  
    @Insert("<script>" +
    "insert into `s_invite` " +
    "  <set>" +
   
    "    <if test='info.userId != null'>" +
    "      `user_id` = #{info.userId}, " +
    "    </if>" +
    "    <if test='info.inviteId != null'>" +
    "      `invite_id` = #{info.inviteId}, " +
    "    </if>" +
    "    <if test='info.createTime != null'>" +
    "      `create_time` = #{info.createTime} " +
    "    </if>" +
    "  </set>" +
    "</script>")
	@Options(useGeneratedKeys = true, keyProperty = "id")
	int save(@Param("info") InviteDo info);


}